@echo off
:loop
REM Change the ip to match the corresponding SoftLayer account to which we are connecting thru VPN i.e DevOps/AppOps
ping -n 1 10.61.99.99 | find "TTL"
if %ERRORLEVEL%==1 (
	echo "Need to restart the VPN client to build the VPN connection"
	"C:\Program Files (x86)\Array Networks\VpnApp\VPNApp.exe" -connect sslvpn.networklayer.com 443 <SOFTLAYER_ID> <SOFTLAYER_PASSWD> 0
	REM  A wait for a minute to let VPN establish the connection before proceeding.
	timeout 60
	echo "Reconfig the virtual network adapter to use 127.0.0.1 as primary DNS server"
  REM Change the interface name to match the corresponding SoftLayer VPN client's virtual interface	
	netsh interface ipv4 set dns name="Local Area Connection 3" static 127.0.0.1 primary
	timeout 10
	ipconfig /flushdns
	goto loop
)
REM  Wait 1 minutes before the next check
timeout 60
goto loop